<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.DriverManager" %><%--
  Created by IntelliJ IDEA.
  User: 32104
  Date: 2024/6/9
  Time: 下午4:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>删除</title>
</head>
<body>
<%

    request.setCharacterEncoding("utf-8");
    String id = request.getParameter("id");
    if (id != null) {
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            String url = "jdbc:mysql://localhost:3306/student?serverTimezone=Asia/Shanghai";
            String user = "root";
            String password = "root";
            connection = DriverManager.getConnection(url, user, password);
            String deleteSql = "delete from user_info where id=?;";
            preparedStatement = connection.prepareStatement(deleteSql);
            preparedStatement.setString(1, id);
            int i = preparedStatement.executeUpdate();
            if (i > 0) {
%>
<script>
    alert("删除成功")
    window.location.href = "../select/select01.jsp"
</script>
<% }
} catch (Exception e) {
    e.printStackTrace();
} finally {
    try {

    } catch (Exception e) {
        e.printStackTrace();
    }
}
}
%>
</body>
</html>
